<?php

class home extends Frontend_Controller {

    public function __construct() {
        parent::__construct();
    }

    function index() {
        $cache_html = '';
        
        $cache_html = $this->load->view('tamchau/01_home', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
    }
	
	function chuyenmuc(){
		$cache_html = '';
        
        $cache_html = $this->load->view('tamchau/02_chuyenmuc', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}
	function thuvien(){
		$cache_html = '';
        $album_code = 'C610086CCEA47DD3D9036CC8B2349330';
		$this->frontend_data->album = $album = $this->frontend_module->getAlbumByCode($album_code);
		if($album){
			$this->frontend_data->album_images = $album_images = $this->frontend_module->getImageByCode($album_code);
		}
        $cache_html = $this->load->view('tamchau/07_thuvien', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}
	function nhahang(){
		$cache_html = '';
		$this->frontend_data->menu_active = '.menu-nha-hang';
        $this->frontend_data->nhahang_content = $this->frontend_module->getContent(7);
        $this->frontend_data->setmenu_content = $this->frontend_module->getContent(8);
        $this->frontend_data->setmenus = $this->frontend_module->getAlbumByType('restaurant');
        $cache_html = $this->load->view('tamchau/03_nhahang', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}
	
	function tieccuoi(){
		$this->frontend_data->menu_active = '.menu-tiec-cuoi';
		$cache_html = '';
        $this->frontend_data->nhahang_content = $this->frontend_module->getContent(9);
        $this->frontend_data->setmenu_content = $this->frontend_module->getContent(10);
        $this->frontend_data->setmenus = $this->frontend_module->getAlbumByType('wedding');

        

        $cache_html = $this->load->view('tamchau/03_nhahang', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}

	function getSetMenu(){
		$R['result']=-403;
		$R['message']='Data is invalid !';
		$cache_html = '';
		$album_code = $this->input->post('album_code');
		$this->frontend_data->album = $album = $this->frontend_module->getAlbumByCode($album_code);
		if($album){
			$this->frontend_data->album_images = $album_images = $this->frontend_module->getImageByCode($album_code);
			if($album_images){
				$R['result']=1;
				$cache_html = $this->load->view('tamchau/sub/setmenu', $this->frontend_data, true);
				if ($this->enable_cache)
					$this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
				$R['setmenu'] = $cache_html;
			}else $R['message']='Set Menu đang cập nhật, vui lòng quay lại sau !';
		}else $R['message']='Set Menu không tồn tại !';
		echo json_encode($R);
	}

	function sukien(){
		$this->frontend_data->menu_active = '.menu-su-kien';
		$this->frontend_data->event_list = $this->frontend_module->getEventByType('event');
		$cache_html = $this->load->view('tamchau/04_sukien', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}

	function diadiem(){
		$this->frontend_data->menu_active = '.menu-dia-diem';
		$this->frontend_data->event_list = $this->frontend_module->getEventByType('location');
		$cache_html = $this->load->view('tamchau/05_diadiem', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}

	function lienhe(){
		$this->frontend_data->menu_active = '.menu-lien-he';
		
		$cache_html = $this->load->view('tamchau/06_lienhe', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}


	function datcho(){
		$this->frontend_data->menu_active = '.menu-dat-cho';
		
		$cache_html = $this->load->view('tamchau/08_datcho', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}

	function gioithieu(){
		$this->frontend_data->menu_active = '.menu-gioi-thieu';
		$this->frontend_data->content = $this->frontend_module->getContent(11);
		$cache_html = $this->load->view('tamchau/09_content', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}

	function camnhan(){
		$this->frontend_data->menu_active = '.menu-cam-nhan';
		
		$cache_html = $this->load->view('tamchau/06_lienhe', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}

	function hoidap(){
		$this->frontend_data->menu_active = '.menu-hoi-dap';
		$this->frontend_data->content = $this->frontend_module->getContent(12);
		$cache_html = $this->load->view('tamchau/09_content', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
	}

	function loadalbum(){
		$R['result']=-403;
		$R['message']='Data is invalid !';
		$cache_html = '';
		$album_code = $this->input->post('album_code');
		$this->frontend_data->album = $album = $this->frontend_module->getAlbumByCode($album_code);
		if($album){
			
			$this->frontend_data->album_images = $album_images = $this->frontend_module->getImageByCode($album_code);
			if($album_images){
				$R['result']=1;
				$cache_html = $this->load->view('tamchau/sub/chuyenmuc', $this->frontend_data, true);
				if ($this->enable_cache)
					$this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
				$R['album'] = $cache_html;
			}else $R['message']='Album đang cập nhật, vui lòng quay lại sau !';
		}else $R['message']='Mã số truy cập không đúng !';
		echo json_encode($R);
	}
    
}

?>